package com.geng.io.bio;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * bio server
 */
public class BIOserver {
    private static final ExecutorService executor = Executors.newCachedThreadPool();
    public static void main(String[] args) throws IOException {
        int port = 8072;
        ServerSocket serverSocket = null;
        try{
            serverSocket = new ServerSocket(port);
            Socket socket = null;
            while(true){
                socket = serverSocket.accept();
                executor.submit(new BIOServerHandler(socket));
            }
        }finally {
            if(serverSocket != null){
                serverSocket.close();
            }
        }
    }
}
